package com.simple.cloud.domain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.mybatisflex.annotation.*;
import com.mybatisflex.core.mask.Masks;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.simple.cloud.core.base.BaseEntity;

import java.time.LocalDateTime;

import static com.simple.cloud.core.consts.CommonCst.SQL_KEY_GEN;

@ApiModel
@JsonIgnoreProperties(ignoreUnknown = true)
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Table(value = "sys_user")
public class SysUser extends BaseEntity {
    @Id(keyType = KeyType.Generator, value = SQL_KEY_GEN)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    @ApiModelProperty("账户")
    private String username;
    @ApiModelProperty("密码")
//    @JsonIgnore
    @ColumnMask(Masks.PASSWORD) //数据脱敏
    private String password;
    @ApiModelProperty("姓名")
    private String realName;
    @ApiModelProperty("手机")
    private String telephone;
    @ApiModelProperty("邮箱")
    private String email;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty("用户角色")
    @RelationOneToOne(
            joinTable = "sys_user_role",
            joinSelfColumn = "user_id",
            joinTargetColumn = "role_id",
            selfField = "id", targetField = "id")
    private SysRole role;




}
